package cn.gaoyu.context;

import cn.gaoyu.pojo.domain.Tenant;

/**
 * @author: GaoYu
 * @date: 2025/2/5
 * @description: <p>租户上下文调用类</p>
 * @version: 1.0.0
 */
public class TenantContextHolder {
    /**
     * 支持父子线程之间的数据传递
     */
    private static final ThreadLocal<Tenant> CONTEXT = new InheritableThreadLocal<Tenant>();


    public static void setTenant(Tenant tenant) {
        CONTEXT.set(tenant);
    }

    public static Tenant getTenant() {
        return CONTEXT.get();
    }

    public static void clear() {
        CONTEXT.remove();
    }
}
